<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ServiceController
 *
 * @author nmthong
 */
class AjaxController extends Controller{
    // Members
    /**
     * Key which has to be in HTTP USERNAME and PASSWORD headers 
     */
    Const APPLICATION_ID = 'ASCCPE';
 
    /**
     * Default response format
     * either 'json' or 'xml'
     */
    private $format = 'json';
    
    /**
     * @return array action filters
     */    
        public function actionGetSalePoint() {
            try {
                $connetion = Yii::app()->db;
                $query = "SELECT * FROM os_salepoint";
                $command = $connetion->createCommand($query);
                $dataReader = $command->query();
                $row_salepoint = array();
                while (($row = $dataReader->read())!==false) {
                    $row_salepoint[] = $row;
                }
                if (empty($row_salepoint[0]['sale_name'])) {
                    $string = '';
                } else {
                $string = json_encode($row_salepoint); }
                echo $string; 
                
        }  catch (Exception $e) {
            $result=array('data'=>'','status'=>'fail','error'=>$e->getMessage());
            echo $string=json_encode($result);
        }
        
        }
        
        public function actionSearchSalePoint() {
            
        }
        

}
